#include "stdafx.h"
#include "PKCSContentInfo.h"

namespace AppliedCryptography
{
	PKCSContentInfo::PKCSContentInfo(ClassBits classBits, ConstructedBit constucted, TypeNumberBits number)
		: ASN1Sequence(classBits, constucted, number),
		_content(new PKCSContent())
	{
	};

	PKCSContentInfo::PKCSContentInfo(PKCSContent* content)
		: ASN1Sequence(),
		_content(content)
	{
	};

	PKCSContentInfo::~PKCSContentInfo()
	{
		//delete _content;
	};


	ASN1Sequence& PKCSContentInfo::add(ASN1Encodable& obj)
	{
		this->ASN1Sequence::add(obj);
		return *this;
	};

	ASN1Encodable& PKCSContentInfo::get(unsigned int index) const
	{
		return this->ASN1Sequence::get(index);
	};

	PKCSContentInfo& PKCSContentInfo::setContent(PKCSContent& content)
	{
		_content = &content;

		this->add(_content->getPKCSContentType());
		this->add(*_content);

		return *this;
	};

	std::vector<byte> PKCSContentInfo::getContentBits() const
	{
		return this->ASN1Sequence::getContentBits();
	};

	unsigned int PKCSContentInfo::size() const
	{
		return 2;
	};
}; // namespace AppliedCryptography
